package com.pan.download5;

import com.pan.download5.config.ApplicationConfig;
import com.pan.download5.parse.AutoXmlParser;
import com.pan.download5.driver.Basic2Driver;
import com.pan.download5.driver.Driver;
import com.pan.download5.factory.impl.AutoCrawlerDirectoryFactory;
import com.pan.download5.factory.impl.AutoCrawlerPageFactory;

public class AutoDownloadApplication {
    /**
     * 测试
     * @param args
     */
    public static void main(String[] args) {
        String crawlerPath = ApplicationConfig.INSTANCE.getAutoCrawlerPath();
        AutoXmlParser autoXmlParser = new  AutoXmlParser(crawlerPath);
        String url = autoXmlParser.getTargetUrl();
        AutoCrawlerDirectoryFactory autoCrawlerDirectoryFactory = new AutoCrawlerDirectoryFactory(autoXmlParser.getDirectory(),autoXmlParser.getTitle());
        AutoCrawlerPageFactory autoCrawlerPageFactory = new AutoCrawlerPageFactory(autoXmlParser.getPage());
        Driver driver = new Basic2Driver(
                autoCrawlerDirectoryFactory,
                autoCrawlerPageFactory
        );
        driver.run(url, ApplicationConfig.INSTANCE.getTaskThreadCount());
    }
}
